package com.proxy;

/**
 * @author cyf
 * @description
 * @create 2018-09-20 14:48
 **/
public class Main {

    public static void main(String[] args) {
//        proxy();
        dynamicProxy();
    }

    /**
     * 动态代理测试
     */
    public static void dynamicProxy() {
        UserDao target = new UserDaoImpl();
        UserDao proxy = (UserDao) new DynamicProxyFactory(target).getProxyInstance();
        proxy.save();
    }

    /**
     * 静态代理测试
     */
    public static void proxy(){
        System.out.println("before start!");
        new UserDaoImpl().save();
        System.out.println("before end!");

        System.out.println();

        System.out.println("after start!");
        new UserDaoProxyImpl(new UserDaoImpl()).save();
        System.out.println("after end!");
    }


}
